<?php

require_once 'Zend/View/Helper/Abstract.php';

class Core_View_Helper_RenderApplet extends Zend_View_Helper_Abstract
{
    /**
     * comments
     */
    public function renderApplet($applet)
    {
        $config = Zend_Registry::get('config');

        //create a new instance of view
        $appletView = new Zend_View();
        $appletView->setScriptPath($config->view->applet->path . '/' . $applet);
        $appletView->setHelperPath($config->view->applet->path . '/' . $applet, 'Core_Applet');

        //tell the applet about where it is
        $appletView->page    = $this->view->page;
        $appletView->pageObj = $this->view->pageObj;

        //run the code behind
        if (file_exists($config->view->applet->path . '/' . $applet . '/' . $applet . '.php')) {
           $appletView->$applet();
        }
        return $appletView->render($applet . '.phtml');
    }
}